#pragma once

#include "Types.h"
#include <vcclr.h>

namespace Vortex { namespace Wrapper { namespace Direct3D {

	class NativeShaderInclude;
	ref class D3DXShaderInclude;

	///<summary>Native part of shader include processor</summary>
	class NativeShaderInclude : public ID3DXInclude {
		gcroot<D3DXShaderInclude^> _includeProcessor;
	public:

		NativeShaderInclude(gcroot<D3DXShaderInclude^> includeProcessor);

		///<summary>Opens shader include file data</summary>
		STDMETHOD(Open)(THIS_ D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes);
		
		///<summary>Closes include data</summary>
		STDMETHOD(Close)(THIS_ LPCVOID pData);
	};

	public ref class D3DXShaderInclude abstract {
		NativeShaderInclude* _pNativeInclude;

	internal:

		///<summary>Opens shader include file data</summary>
		HRESULT OpenInclude(THIS_ D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes);

		///<summary>Closes include data</summary>
		HRESULT CloseInclude(THIS_ LPCVOID pData);

	public:

		D3DXShaderInclude();

		~D3DXShaderInclude();

		///<summary>Handle for include</summary>
		property ID3DXInclude* Handle {
			ID3DXInclude* get() { return _pNativeInclude; }
		}

		///<summary>Abstract method to be implemented for providing shader file content based on include</summary>
		virtual String^ GetFileContent(ShaderIncludeType includeType, String^ fileName) abstract;

	};

} } }